﻿using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using Object = UnityEngine.Object;

namespace xasset
{
    public static class Assets
    {
        public const string Bundles = "Bundles";

        public static string Protocol { get; } = Utility.GetProtocol();
        public static string DownloadDataPath { get; set; } = $"{Application.persistentDataPath}/{Bundles}";
        public static byte MaxDownloads { get; set; } = 5;
        public static byte MaxRetryTimes { get; set; } = 2;


        [RuntimeInitializeOnLoadMethod]
        private static void Initialize()
        {
            var gameObject = new GameObject("xasset", typeof(Downloader));
            Object.DontDestroyOnLoad(gameObject);
        }
        
        public static string GetDownloadDataPath(string filename)
        {
            var path = $"{DownloadDataPath}/{filename}";
            Utility.CreateDirectoryIfNecessary(path);
            return path;
        }
    }
}